﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kingdee.BOS.Business.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.ControlModel;
using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Collections.Generic;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Core.DynamicForm;
using Kingdee.BOS.Core.List;
using Kingdee.BOS.Core.Metadata;
using Kingdee.BOS.Core.NotePrint;
using Kingdee.BOS.Core.Report;
using Kingdee.BOS.Orm.Metadata.DataEntity;
using Kingdee.BOS.Resource;
using Kingdee.BOS.ServiceHelper.Report;
using Kingdee.BOS.Util;
using Newtonsoft.Json;
using Kingdee.BOS;
using Kingdee.BOS.JSON;

namespace DzInfo.DynamicFormModelPlugIn.Test
{
    public class NoteStatementSetup : AbstractNotePrintSettingPlugIn
    {
        private const string ENTRY_KEY = "FEntity";

        private const string EmptyValue = "empty";

        private const string ENTRY_KEYADVANTAGE = "FEntityAdvantage";

        private const string FIELD_FCHECKBOX = "FAdvantageEnable";

        private const string FIELD_FPRINTER = "FPrinter";

        private const string FIELD_FCOMBOMULTEM = "FComboMulTem";

        private const string FIELD_FCHKECONOMIZE = "FChkEconomize";

        private const string FIELD_FUSEPAPERINFO = "FUsePaperInfo";

        private List<EnumItem> _noteTemplates;

        private string _strSetting = "";

        public List<EnumItem> NoteTemplates
        {
            get
            {
                if (_noteTemplates == null)
                {
                    if (((AbstractDynamicFormPlugIn)this).View.ParentFormView != null)
                    {
                        _noteTemplates = GetValidNoteTemplates(this.View.Context, ((AbstractDynamicFormPlugIn)this).View.ParentFormView.OpenParameter.FormId);
                        DynamicFormViewPlugInProxy service = ((AbstractDynamicFormPlugIn)this).View.ParentFormView.GetService<DynamicFormViewPlugInProxy>();
                        if (service != null)
                        {
                            ValidNoteTemplatesEventArgs val = new ValidNoteTemplatesEventArgs(_noteTemplates);
                            _noteTemplates = service.FireGetValidNoteTemplatesAll(val);
                        }
                    }
                    else
                    {
                        _noteTemplates = new List<EnumItem>();
                    }
                }
                return _noteTemplates;
            }
        }

        private string ParentViewDefaultNote
        {
            get
            {
                if (((AbstractDynamicFormPlugIn)this).View.ParentFormView == null)
                {
                    return null;
                }
                return ((AbstractDynamicFormPlugIn)this).View.ParentFormView.BillBusinessInfo.GetForm().Note;
            }
        }

        protected override string FieldKeySetToAllUser => "FSetToAllUser";

        protected override string FieldKeySetToSpecificUser => "FSetToSpecificUser";

        public override void BeforeBindData(EventArgs e)
        {
            //IL_0064: Unknown result type (might be due to invalid IL or missing references)
            //IL_006a: Expected O, but got Unknown
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView == null)
            {
                return;
            }
            BindPaperType();
            BindOrientation();
            string formId = ((AbstractDynamicFormPlugIn)this).View.ParentFormView.OpenParameter.FormId;
            _strSetting = GetSetupInfo(formId);
            JSONArray val = null;
            if (!string.IsNullOrWhiteSpace(_strSetting) && _strSetting != "<Root />")
            {
                val = new JSONArray(_strSetting);
                string valuebyKey = GetValuebyKey(val, "isnotshowdefault");
                if (!ObjectUtils.IsNullOrEmpty((object)valuebyKey))
                {
                    ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FChkShowDefault", (object)valuebyKey);
                }
            }
            bool flag = false;
            if (val != null)
            {
                foreach (Dictionary<string, object> item in (List<object>)(object)val)
                {
                    if (item.ContainsValue("notePrintParameterSetting"))
                    {
                        flag = true;
                        if (item.ContainsKey("batchPrintPageCount"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FtxtBatchPrintPageCount", item["batchPrintPageCount"]);
                        }
                        if (item.ContainsKey("listSetPrintNumber"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FListSetPrintNumber", item["listSetPrintNumber"]);
                        }
                        else
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FListSetPrintNumber", (object)GetSetPrintNumber());
                        }
                        if (item.ContainsKey("showSelectTemplate"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FShowSelectTemplate", item["showSelectTemplate"]);
                        }
                        else
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FShowSelectTemplate", (object)GetSelectTemplateParm());
                        }
                        if (item.ContainsKey("paperType"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FCmbPaperType", item["paperType"]);
                        }
                        if (item.ContainsKey("paperOrientation"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FCmbOrientation", item["paperOrientation"]);
                        }
                        if (item.ContainsKey("paperHeight"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FPaperHeight", item["paperHeight"]);
                        }
                        if (item.ContainsKey("paperWidth"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FPaperWidth", item["paperWidth"]);
                        }
                        if (item.ContainsKey("marginTop"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FMarginTop", item["marginTop"]);
                        }
                        if (item.ContainsKey("marginBottom"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FMarginBottom", item["marginBottom"]);
                        }
                        if (item.ContainsKey("marginLeft"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FMarginLeft", item["marginLeft"]);
                        }
                        if (item.ContainsKey("marginRight"))
                        {
                            ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FMarginRight", item["marginRight"]);
                        }
                    }
                }
            }
            if (!flag)
            {
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FListSetPrintNumber", (object)GetSetPrintNumber());
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FShowSelectTemplate", (object)GetSelectTemplateParm());
            }
            if (!((AbstractDynamicFormPlugIn)this).View.Model.GetValue("FCmbPaperType").ToString().Equals("CUSTOM"))
            {
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FPaperHeight").Enabled = false;
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FPaperWidth").Enabled = false;
            }
            if (val == null)
            {
                return;
            }
            for (int i = 0; i < ((List<object>)(object)val).Count; i++)
            {
                string jsonString = val.GetJsonString(i);
                if (jsonString == null)
                {
                    break;
                }
                JSONObject jsonObj = JSONObject.Parse(jsonString);
                BindAdvantageSetting(jsonObj);
            }
        }

        private string GetValuebyKey(JSONArray jsonArray, string key)
        {
            string result = string.Empty;
            if (jsonArray == null)
            {
                return result;
            }
            for (int i = 0; i < ((List<object>)(object)jsonArray).Count; i++)
            {
                Dictionary<string, object> dictionary = ((List<object>)(object)jsonArray)[i] as Dictionary<string, object>;
                if (dictionary["key"] != null && dictionary["key"].ToString() == key)
                {
                    result = ObjectUtils.Object2String(dictionary["value"]);
                    break;
                }
            }
            return result;
        }

        protected string GetSetupInfo(string formId)
        {
            return PrintServiceHelper.LoadNotePrintPara(((AbstractDynamicFormPlugIn)this).Context, formId, ((AbstractDynamicFormPlugIn)this).Context.UserId);
        }

        public override void AfterCreateModelData(EventArgs e)
        {
            ((AbstractDynamicFormPlugIn)this).AfterCreateModelData(e);
            BindNoteTemplates();
        }

        private void BindNoteTemplates()
        {
            if (((AbstractDynamicFormPlugIn)this).View != null && ((AbstractDynamicFormPlugIn)this).View.ParentFormView != null)
            {
                FieldEditor fieldEditor = ((AbstractDynamicFormPlugIn)this).View.GetFieldEditor("FReportNote", 0);
                ComboFieldEditor val = (ComboFieldEditor)(object)((fieldEditor is ComboFieldEditor) ? fieldEditor : null);
                val.SetComboItems(NoteTemplates);
                FieldEditor fieldEditor2 = ((AbstractDynamicFormPlugIn)this).View.GetFieldEditor("FComboMulTem", 0);
                ComboFieldEditor val2 = (ComboFieldEditor)(object)((fieldEditor2 is ComboFieldEditor) ? fieldEditor2 : null);
                if (val2 != null)
                {
                    val2.SetComboItems(NoteTemplates);
                }
            }
        }

        public override void AfterBindData(EventArgs e)
        {
            base.AfterBindData(e);
            BindNoteSettings();
            ((AbstractDynamicFormPlugIn)this).View.GetControl("FReportNote").SetCustomPropertyValue("editable", (object)true);
            ((AbstractDynamicFormPlugIn)this).View.GetControl("FComboMulTem").SetCustomPropertyValue("editable", (object)true);
        }

        private void BindNoteSettings()
        {
            //IL_002f: Unknown result type (might be due to invalid IL or missing references)
            //IL_0035: Expected O, but got Unknown
            //IL_0035: Unknown result type (might be due to invalid IL or missing references)
            //IL_003b: Expected O, but got Unknown
            //IL_0071: Unknown result type (might be due to invalid IL or missing references)
            //IL_0077: Expected O, but got Unknown
            //IL_0027: Unknown result type (might be due to invalid IL or missing references)
            //IL_002d: Expected O, but got Unknown
            JSONArray val = null;
            if (!string.IsNullOrWhiteSpace(_strSetting) && _strSetting != "<Root />")
            {
                val = new JSONArray(_strSetting);
            }
            else
            {
                val = new JSONArray();
                JSONObject val2 = new JSONObject();
                ((Dictionary<string, object>)(object)val2).Add("key", (object)"printtype");
                ((Dictionary<string, object>)(object)val2).Add("value", (object)"0");
                ((List<object>)(object)val).Add((object)val2);
                string parentViewDefaultNote = ParentViewDefaultNote;
                if (!string.IsNullOrWhiteSpace(parentViewDefaultNote))
                {
                    JSONObject val3 = new JSONObject();
                    ((Dictionary<string, object>)(object)val3).Add("key", (object)"");
                    ((Dictionary<string, object>)(object)val3).Add("value", (object)parentViewDefaultNote);
                    ((List<object>)(object)val).Add((object)val3);
                }
            }
            int entryRowCount = ((AbstractDynamicFormPlugIn)this).View.Model.GetEntryRowCount("FEntity");
            if (entryRowCount == 1)
            {
                ((AbstractDynamicFormPlugIn)this).View.Model.DeleteEntryRow("FEntity", 0);
            }
            ((AbstractDynamicFormPlugIn)this).View.Model.CreateNewEntryRow("FEntity");
            if (NoteTemplates.Count > 0 && val != null && ((List<object>)(object)val).Count > 1)
            {
                object obj = getTemplateKey(val);
                if (ObjectUtils.IsNullOrEmptyOrWhiteSpace(obj))
                {
                    obj = ParentViewDefaultNote;
                }
                ((AbstractDynamicFormPlugIn)this).Model.SetValue("FReportNote", obj);
            }
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FEntity");
            BindingNotePrintExportSetting(val);
            NotePrintExportTypeVisable();
        }

        public override void DataChanged(DataChangedEventArgs e)
        {
            if (((AbstractElement)e.Field).Key == "FCmbPaperType")
            {
                object value = ((AbstractDynamicFormPlugIn)this).Model.GetValue("FCmbPaperType");
                SetPaperSize(ObjectUtils.Object2String(value));
            }
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView != null)
            {
                _noteTemplates = GetValidNoteTemplates(((AbstractDynamicFormPlugIn)this).View.Context, ((AbstractDynamicFormPlugIn)this).View.ParentFormView.OpenParameter.FormId);
                BindNoteTemplates();
                ((AbstractDynamicFormPlugIn)this).View.UpdateView("FReportNote");
            }
        }

        private object getTemplateKey(JSONArray jsonArray)
        {
            object result = null;
            foreach (Dictionary<string, object> item in (List<object>)(object)jsonArray)
            {
                if (!"printtype".Equals(item["key"]) && !"isnotshowdefault".Equals(item["key"]))
                {
                    result = item["value"];
                    break;
                }
            }
            return result;
        }

        private List<EnumItem> GetValidNoteTemplates(Context ctx, string formID)
        {
            //IL_002b: Unknown result type (might be due to invalid IL or missing references)
            //IL_0031: Expected O, but got Unknown
            bool isNotShowDefault = StringUtils.EqualsIgnoreCase(ObjectUtils.Object2String(((AbstractDynamicFormPlugIn)this).View.Model.GetValue("FChkShowDefault")), "true");
            List<EnumItem> list = new List<EnumItem>();
            RequestTemplateParam val = new RequestTemplateParam();
            val.FormId = formID;
            val.View = ((AbstractDynamicFormPlugIn)this).View.ParentFormView;
            val.IsNotShowDefault = isNotShowDefault;
            val.IsFireGetValidNoteTemplatesPlugIn = false;
            val.IsAddEmptyItem = true;
            val.IsNoteStatementSetup = true;
            RequestTemplateParam val2 = val;
            return PrintServiceHelper.GetEnableNotePrintTemplate(((AbstractDynamicFormPlugIn)this).View.Context, val2);
        }

        public override void ButtonClick(ButtonClickEventArgs e)
        {
            //IL_0049: Unknown result type (might be due to invalid IL or missing references)
            //IL_004f: Expected O, but got Unknown
            //IL_0065: Unknown result type (might be due to invalid IL or missing references)
            //IL_006b: Expected O, but got Unknown
            //IL_0093: Unknown result type (might be due to invalid IL or missing references)
            //IL_0099: Expected O, but got Unknown
            //IL_0147: Unknown result type (might be due to invalid IL or missing references)
            //IL_014e: Expected O, but got Unknown
            //IL_01bb: Unknown result type (might be due to invalid IL or missing references)
            //IL_01c2: Expected O, but got Unknown
            //IL_00ff: Unknown result type (might be due to invalid IL or missing references)
            //IL_0106: Expected O, but got Unknown
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView == null)
            {
                return;
            }
            ((AbstractDynamicFormPlugIn)this).View.ParentFormView.OpenParameter.FormId.ToUpperInvariant();
            if (!(e.Key.ToLowerInvariant() == "fbtnconfirm"))
            {
                return;
            }
            string text = "";
            JSONArray val = new JSONArray();
            object value = ((AbstractDynamicFormPlugIn)this).View.Model.GetValue("FChkShowDefault");
            JSONObject val2 = new JSONObject();
            ((Dictionary<string, object>)(object)val2).Add("key", (object)"isnotshowdefault");
            ((Dictionary<string, object>)(object)val2).Add("value", (object)ObjectUtils.Object2String(value));
            ((List<object>)(object)val).Add((object)val2);
            val2 = new JSONObject();
            ((Dictionary<string, object>)(object)val2).Add("key", (object)"printtype");
            ((Dictionary<string, object>)(object)val2).Add("value", (object)"0");
            ((List<object>)(object)val).Add((object)val2);
            object empty = string.Empty;
            for (int i = 0; i < ((AbstractDynamicFormPlugIn)this).Model.GetEntryRowCount("FEntity"); i++)
            {
                empty = ((AbstractDynamicFormPlugIn)this).Model.GetValue("FReportNote", i);
                if (empty != null && string.Compare(empty.ToString(), "empty", ignoreCase: true) == 0)
                {
                    empty = string.Empty;
                }
                JSONObject val3 = new JSONObject();
                ((Dictionary<string, object>)(object)val3).Add("key", (object)"reportNote");
                ((Dictionary<string, object>)(object)val3).Add("value", empty);
                ((List<object>)(object)val).Add((object)val3);
            }
            JSONObject val4 = new JSONObject();
            ((Dictionary<string, object>)(object)val4).Add("key", (object)"notePrintParameterSetting");
            ((Dictionary<string, object>)(object)val4).Add("batchPrintPageCount", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FtxtBatchPrintPageCount"));
            ((Dictionary<string, object>)(object)val4).Add("showSelectTemplate", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FShowSelectTemplate"));
            ((Dictionary<string, object>)(object)val4).Add("listSetPrintNumber", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FListSetPrintNumber"));
            ((List<object>)(object)val).Add((object)val4);
            JSONObject val5 = new JSONObject();
            ((Dictionary<string, object>)(object)val5).Add("key", (object)"notePrintExportSetting");
            ((Dictionary<string, object>)(object)val5).Add("useNotePrintExportDefault", ((AbstractDynamicFormPlugIn)this).View.Model.GetValue("FUseNotePrintExportDefault"));
            ((Dictionary<string, object>)(object)val5).Add("notePrintExportFileType", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FNotePrintExportFileType"));
            ((Dictionary<string, object>)(object)val5).Add("notePrintExportType", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FNotePrintExportType"));
            ((List<object>)(object)val).Add((object)val5);
            bool isUsePaperInfo = false;
            if (!SaveAdvantage(val, out isUsePaperInfo))
            {
                return;
            }
            if (isUsePaperInfo)
            {
                string text2 = ObjectUtils.Object2String(((AbstractDynamicFormPlugIn)this).Model.GetValue("FCmbPaperType"));
                int num = ObjectUtils.Object2Int(((AbstractDynamicFormPlugIn)this).Model.GetValue("FPaperHeight"), 0);
                int num2 = ObjectUtils.Object2Int(((AbstractDynamicFormPlugIn)this).Model.GetValue("FPaperWidth"), 0);
                if ((text2.ToUpperInvariant() == "CUSTOM" && (num == 0 || num2 == 0)) || ObjectUtils.IsNullOrEmptyOrWhiteSpace((object)text2.ToUpperInvariant()))
                {
                    ((AbstractDynamicFormPlugIn)this).View.ShowErrMessage(ResManager.LoadKDString("套打设置【高级】页签里面启用了纸张设置，请到【参数设置】页签设置纸张规格！", "002013030047813", (SubSystemType)2, new object[0]), "", (MessageBoxType)0);
                    return;
                }
            }
            ((Dictionary<string, object>)(object)val4).Add("paperType", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FCmbPaperType"));
            ((Dictionary<string, object>)(object)val4).Add("paperOrientation", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FCmbOrientation"));
            ((Dictionary<string, object>)(object)val4).Add("paperHeight", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FPaperHeight"));
            ((Dictionary<string, object>)(object)val4).Add("paperWidth", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FPaperWidth"));
            ((Dictionary<string, object>)(object)val4).Add("marginTop", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FMarginTop"));
            ((Dictionary<string, object>)(object)val4).Add("marginBottom", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FMarginBottom"));
            ((Dictionary<string, object>)(object)val4).Add("marginLeft", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FMarginLeft"));
            ((Dictionary<string, object>)(object)val4).Add("marginRight", ((AbstractDynamicFormPlugIn)this).Model.GetValue("FMarginRight"));
            text = val.ToJSONString();
            SaveNotePrintSetting(text);
        }

        private bool GetSetPrintNumber()
        {
            bool result = false;
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView == null)
            {
                return result;
            }
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData != null && ((KeyedCollectionBase<string, DynamicProperty>)(object)((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData.DynamicObjectType.Properties).ContainsKey("FListSetPrintNumber"))
            {
                result = Convert.ToBoolean(((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData["FListSetPrintNumber"]);
            }
            return result;
        }

        private bool GetSelectTemplateParm()
        {
            bool result = false;
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView == null)
            {
                return result;
            }
            string text = "FShowSelectTemplate";
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView is IListView)
            {
                text = "FListShowSelectTemplate";
            }
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData != null && ((KeyedCollectionBase<string, DynamicProperty>)(object)((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData.DynamicObjectType.Properties).ContainsKey(text) && ((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData[text] != null)
            {
                result = ObjectUtils.Object2Bool(((AbstractDynamicFormPlugIn)this).View.ParentFormView.Model.ParameterData[text], false);
            }
            return result;
        }

        private void BindAdvantageSetting(JSONObject jsonObj)
        {
            if (((Dictionary<string, object>)(object)jsonObj).ContainsKey("key") && !(ObjectUtils.Object2String(((Dictionary<string, object>)(object)jsonObj)["key"]) != "advantageSetting"))
            {
                ReportAdvantageSetting val = JsonConvert.DeserializeObject<ReportAdvantageSetting>(((object)jsonObj).ToString());
                ((AbstractDynamicFormPlugIn)this).View.Model.CreateNewEntryRow("FEntityAdvantage");
                int num = ((AbstractDynamicFormPlugIn)this).View.Model.GetEntryRowCount("FEntityAdvantage") - 1;
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FAdvantageEnable", (object)val.Enable, num);
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FComboMulTem", (object)val.TemplateId, num);
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FPrinter", (object)val.Printer, num);
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FChkEconomize", (object)val.IsEconomizePaper, num);
                ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FUsePaperInfo", (object)val.UsePaperInfo, num);
            }
        }

        private bool SaveAdvantage(JSONArray jsonSetting, out bool isUsePaperInfo)
        {
            //IL_0029: Unknown result type (might be due to invalid IL or missing references)
            //IL_0030: Expected O, but got Unknown
            isUsePaperInfo = false;
            int entryRowCount = ((AbstractDynamicFormPlugIn)this).Model.GetEntryRowCount("FEntityAdvantage");
            new StringBuilder();
            List<int> list = new List<int>();
            bool flag = false;
            for (int i = 0; i < entryRowCount; i++)
            {
                ReportAdvantageSetting val = new ReportAdvantageSetting();
                val.Enable = ObjectUtils.Object2Bool(((AbstractDynamicFormPlugIn)this).Model.GetValue("FAdvantageEnable", i), false);
                val.TemplateId = ObjectUtils.Object2String(((AbstractDynamicFormPlugIn)this).Model.GetValue("FComboMulTem", i));
                val.Printer = ObjectUtils.Object2String(((AbstractDynamicFormPlugIn)this).Model.GetValue("FPrinter", i));
                val.IsEconomizePaper = ObjectUtils.Object2Bool(((AbstractDynamicFormPlugIn)this).Model.GetValue("FChkEconomize", i), false);
                val.UsePaperInfo = ObjectUtils.Object2Bool(((AbstractDynamicFormPlugIn)this).View.Model.GetValue("FUsePaperInfo", i), false);
                isUsePaperInfo = ((!isUsePaperInfo) ? val.UsePaperInfo : isUsePaperInfo);
                if (val.Enable && ObjectUtils.IsNullOrEmptyOrWhiteSpace((object)val.TemplateId) && (ObjectUtils.IsNullOrEmptyOrWhiteSpace((object)val.TemplateId) || StringUtils.EqualsIgnoreCase(val.TemplateId, "empty")))
                {
                    if (!flag)
                    {
                        flag = true;
                    }
                    list.Add(i);
                }
                JSONObject item = JSONObject.Parse(JsonUtil.Serialize((object)val, true));
                ((List<object>)(object)jsonSetting).Add((object)item);
            }
            if (flag)
            {
                ShowNullTemplate(list);
                return false;
            }
            return true;
        }

        private void BindingNotePrintExportSetting(JSONArray jsonArray)
        {
            if (jsonArray == null)
            {
                return;
            }
            foreach (Dictionary<string, object> item in (List<object>)(object)jsonArray)
            {
                if (item.ContainsValue("notePrintExportSetting"))
                {
                    if (item.ContainsKey("useNotePrintExportDefault"))
                    {
                        ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FUseNotePrintExportDefault", item["useNotePrintExportDefault"]);
                    }
                    if (item.ContainsKey("notePrintExportFileType"))
                    {
                        ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FNotePrintExportFileType", item["notePrintExportFileType"]);
                    }
                    if (item.ContainsKey("notePrintExportType"))
                    {
                        ((AbstractDynamicFormPlugIn)this).View.Model.SetValue("FNotePrintExportType", item["notePrintExportType"]);
                    }
                }
            }
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FUseNotePrintExportDefault");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FNotePrintExportFileType");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintXls");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintXlsx");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintPDF");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintByPage");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintByContent");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintByMerge");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintByBillTempId");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdNotePrintByMulFile");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FRdByDynamicPaper");
            ((AbstractDynamicFormPlugIn)this).View.UpdateView("FNotePrintExportType");
        }

        private void NotePrintExportTypeVisable()
        {
            if (((AbstractDynamicFormPlugIn)this).View.ParentFormView is IMoveReportView)
            {
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByMulFile").Visible = true;
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByBillTempId").Visible = false;
            }
            else if (((AbstractDynamicFormPlugIn)this).View.ParentFormView != null && (((AbstractElement)((AbstractDynamicFormPlugIn)this).View.ParentFormView.BillBusinessInfo.GetForm()).ElementType == 400 || ((AbstractElement)((AbstractDynamicFormPlugIn)this).View.ParentFormView.BillBusinessInfo.GetForm()).ElementType == 100))
            {
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByMulFile").Visible = false;
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByBillTempId").Visible = true;
            }
            else
            {
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByMulFile").Visible = false;
                ((AbstractDynamicFormPlugIn)this).View.GetControl("FRdNotePrintByBillTempId").Visible = false;
            }
        }
    }
}
